Ext.define('BM.controller.TradeValids', {
    extend: 'Ext.app.Controller',
    init: function() {
         this.control({
            'adddownpay button[action=save]': {
                click: this.onSaveDownPay
            },
            'adddownpay>form textfield[name=addDownPay]': {
                change: this.onChangeDownPay
            },
            'changetoken button[action=save]': {
                click: this.onSaveChangeToken
            },
            'changetoken>form textfield[name=newHandTokenNum]' : {
            	change: this.onChangeToken
            }
        });
    },
    onSaveDownPay: function(button) {
        var win = button.up('window'),
        form   = win.down('form'),
        record = form.getRecord(),
        values = form.getValues();
        
	    win.close();
    },
    onChangeDownPay:function(_field,_new,_old){
    	
    	var _form = _field.up('form');
    	var _orginal = _form.down('textfield[name=downPayAmount]');
    	var _total =   _form.down('textfield[name=totalDownPay]');
    	
    	_total.setValue(_new+_orginal.getValue());
    },
    onChangeToken:function(_field,_new,_old){
    	alert(_new);
    	var _form = _field.up('form');
    	var _orginalNum = _form.down('textfield[name=handTokenNum]').getValue();
    	if(_new == _orginalNum)
    	Ext.Msg.alert("系统提示","手牌号与原手牌号相同！");
    	
    },
    onSaveChangeToken:function(button){
    
    
    }
    
});